package com.tool.base.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.tool.base.entity.BsStaticData;

public interface BsStaticDataDAO
		extends PagingAndSortingRepository<BsStaticData, Long>, JpaSpecificationExecutor<BsStaticData> {
	@Query("select ssd from BsStaticData ssd, BsStaticType sst where ssd.typeId = sst.id and ssd.state = 1 and sst.state = 1 and sst.code = ?1 order by ssd.sort asc")
	public List<BsStaticData> getValidStaticDatasByTypeCode(String paramString);

	@Query("select ssd from BsStaticData ssd, BsStaticType sst where ssd.typeId = sst.id and ssd.state = 1 and sst.state = 1 and sst.code = ?1 and ssd.code = ?2")
	public BsStaticData getStaticData(String paramString1, String paramString2);

	@Query("select ssd from BsStaticData ssd where ssd.state=1 and ssd.code=?1")
	public List<BsStaticData> getByCode(String paramString);

	@Query("select ssd from BsStaticData ssd where ssd.state=1 and ssd.value=?1")
	public List<BsStaticData> getByValue(String paramString);

	@Query("select ssd from BsStaticData ssd where ssd.state=1 and ssd.code=?2 and ssd.typeId=?1 ")
	public List<BsStaticData> getByNewCode(Long paramLong, String paramString);

	@Query("select ssd from BsStaticData ssd where ssd.state=1 and ssd.value=?2 and ssd.typeId=?1 ")
	public List<BsStaticData> getByNewValue(Long paramLong, String paramString);

	@Modifying
	@Query("UPDATE BsStaticData bsd SET bsd.state=-1 WHERE bsd.id=?1")
	void deletes(Long paramLong);

	@Query("select ssd from BsStaticData ssd, BsStaticType sst where ssd.typeId = sst.id and ssd.state = 1 and sst.state = 1 and ssd.value=?2 and sst.code=?1 ")
	BsStaticData getStaticDataByTypeCodeAndValue(String paramString1, String paramString2);

	@Query("select value from BsStaticData where code = 'video' and state = 1")
	String getVideoPath();
}